package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo10Union {
  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf()
      .setAppName("make")
      .setMaster("local")


    val sc = new SparkContext(conf)

    /**
      * union算子合并两个rdd, 两个rdd的类型必须一致
      *
      * 并不是在物理层面的合并,而是在逻辑层面的合并
      *
      */

    val rdd1: RDD[Int] = sc.parallelize(List(1, 2, 3, 4, 5))
    val rdd2: RDD[Int] = sc.parallelize(List(6, 7, 8, 9, 10))


    val unionRDD: RDD[Int] = rdd1.union(rdd2)


    unionRDD.foreach(println)


  }

}
